<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>191-用工厂模式的函数创建对象.html</title>
</head>
<body>
	
</body>
<script>
	function createPerson(name,age){
		var obj = {};
		obj.name = name;
		obj.age = age;
		obj.sayName = function(){
			console.log("I am chris"+this.name);
		}
		obj.sayAge = function(){
			console.log("I amchris"+this.age);
		}
		return obj;
	}
	var person1 = createPerson("chris",22);
	person1.sayName();
	person1.sayAge();
	console.log(person1);

	var person2 = createPerson("chris",22);
	person2.sayName();
	person2.sayAge();
	console.log(person2);
</script>
</html>